package com.example.anju.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.anju.entity.Orders;
import com.example.anju.entity.Result;
import com.example.anju.service.OrdersService;

@RestController
@RequestMapping("order")
public class OrdersController {
	@Autowired
	private OrdersService orderService;

	// 通过orders_id查询订单
	@PostMapping("/findOrdersByOrdersId")
	public Result findOrdersByOrdersId(@RequestBody Orders orders) {
		return orderService.findOrdersByOrdersId(orders);
	}

	// 通过orders_landlord_id查询订单
	@PostMapping("/findOrdersByLandlordId")
	public Result findOrdersByLandlordId(@RequestBody Orders orders) {
		return orderService.findOrdersByLandlordId(orders);
	}

	// 通过orders_tenant_id查询订单
	@PostMapping("/findOrdersByTenantId")
	public Result findOrdersByTenantId(@RequestBody Orders orders) {
		return orderService.findOrdersByTenantId(orders);
	}

	// 通过order_landlord_id和check_orders查询订单
	@PostMapping("/findOrdersByLandlordIdAndCheck")
	public Result findOrdersByLandlordIdAndCheck(@RequestBody Orders orders) {
		return orderService.findOrdersByLandlordIdAndCheck(orders);
	}

	// 通过order_tenant_id和check_orders查询订单
	@PostMapping("/findOrdersByTenantIdAndCheck")
	public Result findOrdersByTenantIdAndCheck(@RequestBody Orders orders) {
		return orderService.findOrdersByTenantIdAndCheck(orders);
	}

	// 通过orders_tenant_id和orders_house_id查询订单
	@PostMapping("/findOrdersByTenantIdAndHouseId")
	public Result findOrdersByTenantIdAndHouseId(@RequestBody Orders orders) {
		return orderService.findOrdersByTenantIdAndHouseId(orders);
	}

	// 生成订单
	@PostMapping("/publishOrders")
	public Result publishOrders(@RequestBody Orders orders) {
		return orderService.publishOrders(orders);
	}

	// 通过orders_id修改订单状态
	@PostMapping("/postOrdersByOrdersIdAndCheck")
	public Result postOrdersByOrdersIdAndCheck(@RequestBody Orders orders) {
		return orderService.postOrdersByOrdersIdAndCheck(orders);
	}
}
